home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / import-export / ie-errors.scm next >
Encoding:
Text File  |  1994-09-27  |  5.6 KB  |  161 lines  |  [TEXT/CCL2]

  1. ;;; Error checks & calls for the import-export code
  2.  
  3. ;;; this is called at the end of import-export to look for
  4. ;;;  a) exported entities that were never found
  5. ;;;  b) imported entities that were never found
  6. ;;;  c) renamed entities that were never found
  7. ;;;  d) hidden entities that were never found
  8.  
  9. ;;;  %%% Lots of these should be phase errors - jcp
  10.  
  11. (define (maybe-remove-con-prefix name)
  12.   (let ((str (symbol->string name)))
  13.     (if (has-con-prefix? str)
  14.     (remove-con-prefix str)
  15.     str)))
  16.  
  17. (define (check-missing-names)
  18.   (dolist (export (module-exports *module*))
  19.     (remember-context export
  20.       (signal-missing-export export)))
  21.   (dolist (import-decl (module-imports *module*))
  22.     (remember-context import-decl
  23.       (with-slots import-decl (mode specs renamings) import-decl
  24.         ;; *** I'm confused.  Aren't these errors already detected
  25.     ;; *** by import-all-entities and import-named-entities?
  26.     ;; jcp: no - a final check is needed after all symbols have moved.
  27.         (cond ((eq? mode 'all)
  28.            (dolist (entity specs)
  29.          (signal-unused-hiding
  30.            (entity-name entity)
  31.            (import-decl-module-name import-decl))))
  32.           (else
  33.            (dolist (entity specs)
  34.          (signal-entity-not-found
  35.            (entity-name entity)
  36.            (import-decl-module-name import-decl)))))
  37.     (find-unused-renamings renamings import-decl)))))
  38.  
  39. (define (find-unused-renamings renamings import-decl)
  40.   (dolist (r renamings)
  41.     (when (not (renaming-referenced? r))
  42.       (remember-context r
  43.     (signal-unused-renaming (renaming-from r)
  44.                 (import-decl-module-name import-decl))))))
  45.  
  46. (define (check-duplicates l entity)
  47.   (when (not (null? (find-duplicates l)))
  48.     (signal-duplicate-names-in-entity entity)))
  49.  
  50. ;;; There are a ton of possible errors in import-export.  All error
  51. ;;; calls are found here:
  52.  
  53. (define (signal-missing-export export)
  54.   (recoverable-error 'missing-export
  55.     "Module ~A exports ~A, but provides no definition for it."
  56.     *module-name* export))
  57.  
  58. (define (signal-unused-renaming name module-name)
  59.   (recoverable-error 'unused-renaming
  60.     "The name ~a is included in the renaming list of an import declaration,~%~
  61.      but is not among the entities being imported from module ~a."
  62.     name module-name))
  63.  
  64. (define (signal-unused-hiding name module-name)
  65.   (recoverable-error 'unused-hiding
  66.     "The name ~a is included in the hiding list of an import declaration,~%~
  67.      but is not among the entities exported from module ~a."
  68.     name module-name))
  69.  
  70. (define (signal-multiple-name-conflict name old-local-name def)
  71.   (recoverable-error 'multiple-name-conflict
  72.     "In module ~A, the symbol ~A from module ~A~%is known as both ~A and ~A."
  73.     *module-name* (def-name def) (def-module def) name old-local-name))
  74.  
  75. ;;; This should show the modules available to the user!
  76.  
  77. (define (signal-undefined-module-import name)
  78.   (phase-error 'undefined-module-import
  79.       "Cannot find module ~A, imported by module ~A."
  80.            name *module-name*))
  81.  
  82. (define (signal-self-import name)
  83.   (phase-error 'self-import
  84.            "Module ~A cannot import itself."
  85.            name))
  86.  
  87. (define (signal-missing-prelude)
  88.   (fatal-error 'missing-prelude "Can't find module Prelude."))
  89.  
  90. (define (signal-missing-prelude-core)
  91.   (fatal-error 'missing-prelude "Can't find module PreludeCore."))
  92.  
  93. (define (signal-export-not-imported name)
  94.   (recoverable-error 'export-not-imported
  95.     "Module ~A is exported from ~A,~%~
  96.      but is not also imported into that module."
  97.     name *module-name*))
  98.  
  99. (define (signal-entity-not-found name module-name)
  100.   (phase-error 'entity-not-found
  101.     "The entity ~a is not exported from module ~a." name module-name))
  102.  
  103. (define (signal-synonym-needs-dots name module-name)
  104.   (declare (ignore module-name))
  105.   (phase-error 'synonym-needs-dots
  106.     "The entity ~a is a type synonym; to name it in an import or export~%~
  107.      list, you must use `~a(..)'."
  108.     name name))
  109.  
  110. (define (signal-wrong-definition expected name module-name)
  111.   (phase-error 'wrong-definition
  112.     "The entity ~a does not name a ~a in module ~a."
  113.     name expected module-name))
  114.  
  115. (define (signal-abstract-type name module-name)
  116.   (phase-error 'abstract-type
  117.     "The entity ~a names an abstract type in module ~a;~%~
  118.      the constructors for this type are not available."
  119.     name module-name))
  120.  
  121. (define (signal-extra-constituent entity name what)
  122.   (phase-error 'extra-constituent
  123.     "The entity ~a includes the ~a name ~a,~%~
  124.      which is not present in its definition."
  125.     (sz entity 20) what (maybe-remove-con-prefix name)))
  126.  
  127. (define (signal-missing-constituent entity name what)
  128.   (phase-error 'missing-constituent
  129.     "The entity ~a does not include the ~a name ~a,~%~
  130.      which is part of its definition."
  131.     (sz entity 20) what (maybe-remove-con-prefix name)))
  132.  
  133. (define (signal-duplicate-names-in-entity entity)
  134.   (phase-error 'duplicate-names-in-entity
  135.     "The entity ~a includes duplicate names."
  136.     (sz entity 30)))
  137.  
  138. (define (signal-export-method-var name def)
  139.   (phase-error/objs 'export-method-var (list def)
  140.     "The method variable ~a must be exported with its class.~%~
  141.      It can not be named individually in an export list."
  142.     name))
  143.  
  144. (define (signal-prelude-renaming def name)
  145.   (recoverable-error 'cant-rename-core
  146.      "Names in PreludeCore cannot be renamed: ~a was renamed to ~a"
  147.      (def-name def) name))
  148.  
  149. (define (signal-non-local-fixity op)
  150.   (recoverable-error 'fixity-must-be-local
  151.      "The fixity for ~A will be ignored since it is not defined in this module"
  152.      op))
  153.  
  154. ;;; This should be syntacticly illegal
  155.  
  156. (define (signal-fixity-not-var/con op)
  157.   (recoverable-error 'fixity-requires-var-or-con
  158.      "The fixity for ~A will be ignored since it is not a value or constructor"
  159.      op))
  160.  
  161.